package tcc.wa.model.util;

import tcc.wa.model.AlertType;

/**
 * Utility class for Alert Type.
 */
public abstract class AlertTypeUtils {

	/**
	 * Parses the Alert Type from an integer value.
	 *
	 * @param value the value
	 * @return the alert type
	 */
	public static AlertType parse(int value) {
		switch (value) {
		case 0:
			return AlertType.HIGH_TEMPERATURE;
		case 1:
			return AlertType.LOW_TEMPERATURE;
		case 2:
			return AlertType.RAIN;
		default:
			return null;
		}
	}

	/**
	 * Translates the Alert type.
	 *
	 * @param type the type
	 * @return a string equivalent to the Alert Type
	 */
	public static String translate(AlertType type) {
		switch (type) {
		case HIGH_TEMPERATURE:
			return "Alta Temperatura";
		case LOW_TEMPERATURE:
			return "Baixa Temperatura";
		case RAIN:
			return "Chuva";
		default:
			return null;
		}
	}

	/**
	 * Converts to int.
	 *
	 * @param type the type
	 * @return an integer equivalent to the Alert Type
	 */
	public static int convertToInt(AlertType type) {
		switch (type) {
		case HIGH_TEMPERATURE:
			return 0;
		case LOW_TEMPERATURE:
			return 1;
		case RAIN:
			return 2;
		default:
			return -1;
		}
	}
}
